package com.beyond.trace.service.impl.agricultural;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beyond.trace.domain.agricultural.AgriculturalIdentify;
import com.beyond.trace.domain.agricultural.AgriculturalSuggest;
import com.beyond.trace.mapper.agricultural.AgriculturalIdentifyMapper;
import com.beyond.trace.service.agricultural.IAgriculturalIdentifyService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 农技病害查询
 * @Author: yaojianbo
 * @Date: 2023-05-22 11:35
 * @Version: 1.0.0
 */
@Service
public class AgriculturalIdentifyServiceImpl extends ServiceImpl<AgriculturalIdentifyMapper, AgriculturalIdentify> implements IAgriculturalIdentifyService {
    @Override
    public List<AgriculturalIdentify> getIdentifyList(AgriculturalIdentify agriculturalIdentify) {

        LambdaQueryWrapper<AgriculturalIdentify> queryWrapper = new LambdaQueryWrapper<>();

        if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
            queryWrapper.eq(AgriculturalIdentify::getDepartId,SecurityUtils.getUserDepartId());
        }

        if(StringUtils.isNotEmpty(agriculturalIdentify.getCycle())) {
            queryWrapper.like(AgriculturalIdentify::getCycle,agriculturalIdentify.getCycle());
        }
        if(StringUtils.isNotEmpty(agriculturalIdentify.getIdentify())) {
            queryWrapper.eq(AgriculturalIdentify::getIdentify,agriculturalIdentify.getIdentify());
        }
        if(agriculturalIdentify.getStatus() != null) {
            queryWrapper.eq(AgriculturalIdentify::getStatus,agriculturalIdentify.getStatus());
        }
        return this.list(queryWrapper);
    }
}
